package com.sakiko.aspects_part2;
// todo: aop_06

import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(10) // 设置优先级
public class TxAspect {

    @Before("com.sakiko.pointcuts_part2.MyPointcut.pointcut06()")
    public void beginTransaction() {
        System.out.println("TxAspect.before");
    }

    @AfterReturning("com.sakiko.pointcuts_part2.MyPointcut.pointcut06()")
    public void commitTransaction() {
        System.out.println("TxAspect.commit");
    }

    @AfterThrowing("com.sakiko.pointcuts_part2.MyPointcut.pointcut06()")
    public void rollback() {
        System.out.println("TxAspect.rollback");
    }
}
